home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0186_RE: VESA BANK SWITCHING.pas < prev   
Pascal/Delphi Source File  |  1995-02-28  |  3KB  |  92 lines

  1.  
  2. {$X+}
  3. uses crt;
  4.  
  5. type
  6.  ModeInfoBlock = record
  7.         ModeAttributes     : word;    { mode attributes                    }
  8.         WinAAttributes     : byte;    { window A attributes                }
  9.         WinBAttributes     : byte;    { window B attributes                }
  10.         WinGranularity     : word;    { window granularity                 }
  11.         WinSize            : word;    { window size                        }
  12.         WinASegment        : word;    { window A start segment             }
  13.         WinBSegment        : word;    { window B start segment             }
  14.         WinFuncPtr         : pointer; { pointer to windor function         }
  15.         BytesPerScanLine   : word;    { bytes per scan line                }
  16.         XResolution        : word;    { horizontal resolution              }
  17.         YResolution        : word;    { vertical resolution                }
  18.         XCharSize          : byte;    { character cell width               }
  19.         YCharSize          : byte;    { character cell height              }
  20.         NumberOfPlanes     : byte;    { number of memory planes            }
  21.         BitsPerPixel       : byte;    { bits per pixel                     }
  22.         NumberOfBanks      : byte;    { number of banks                    }
  23.         MemoryModel        : byte;    { memory model type                  }
  24.         BankSize           : byte;    { bank size in kb                    }
  25.         NumberOfImagePages : byte;    { number of images                   }
  26.         Reserved           : byte;    { reserved for page function         }
  27.         RedMaskSize        : byte;    { size of direct color red mask      }
  28.         RedFieldPosition   : byte;    { bit position of LSB of red mask    }
  29.         GreenMaskSize      : byte;    { size of direct color green mask    }
  30.         GreenFieldPosition : byte;    { bit position of LSB of green mask  }
  31.         BlueMaskSize       : byte;    { size of direct color blue mask     }
  32.         BlueFieldPosition  : byte;    { bit position of LSB of blue mask   }
  33.         RsvdMaskSize       : byte;    { size of direct color reserved mask }
  34.         DirectColorModeInfo: byte;    { Direct Color mode attributes       }
  35.         Reserved2          : array[1..216] of byte; { remainder            }
  36.        end;
  37.  Mogis = ^ModeInfoBlock;
  38.  
  39. var
  40.  modeinfo   : Mogis;
  41.  CurBank, i : integer;
  42.  p          : ^pointer;
  43.  
  44. procedure GetModeInfo(mode : word; var block : modeinfoblock); Assembler;
  45. asm
  46.    mov     ax, 4F01h
  47.    mov     cx, mode
  48.    les     di, block
  49.    int     10h
  50. end;
  51.  
  52. procedure BankSwitch(bank : integer); Assembler;
  53. asm
  54.    mov     ax, bank
  55.    cmp     CurBank, ax
  56.    je      @end
  57.    mov     CurBank, ax
  58.    mov     ax, 4F05h
  59.    xor     bx, bx
  60.    mov     dx, bank
  61.    call    p
  62.  @end:
  63. end;
  64.  
  65. procedure SetVesaMode(mode : word); Assembler;
  66. asm
  67.    mov     ax, 4F02h
  68.    mov     bx, mode
  69.    int     10h
  70. end;
  71.  
  72. procedure SetText; Assembler;
  73. asm
  74.    mov     ax, 3
  75.    int     10h
  76. end;
  77.  
  78. begin
  79.  CurBank := 0;
  80.  SetVesaMode($101);
  81.  GetMem(modeinfo, 256);
  82.  GetModeInfo($101, modeinfo^);
  83.  p := modeinfo^.winfuncptr;
  84.  for i := 0 to 4 do
  85.   begin
  86.    BankSwitch(i);
  87.    Fillchar(mem[$a000:0000], $FFFF, i+1);
  88.   end;
  89.  ReadKey;
  90.  SetText;
  91. end.
  92.